package com.kaifamiao.www.demo.do0906;

import java.sql.*;

public class Demo01 {
    public static void main(String[] args) {
        try {
            //驱动注册
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        String url = "jdbc:mysql://localhost:3306/kfm";
        String sql = "{call total(?,?)}";

        try (//建立连接
             Connection conn = DriverManager.getConnection(url, "root", "");
             // 创建SQL语句
             CallableStatement cls = conn.prepareCall(sql);
        ) {
            //设置参数
            //IN
            cls.setInt(1, 7788);
            //OUT
            cls.registerOutParameter(2, Types.DOUBLE);
            //执行
            cls.execute();
            double a = cls.getDouble(2);
            System.out.println(a);
        }catch(SQLException e){
                e.printStackTrace();
            }
        }
    }
